﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RPGOnline
{
    public partial class ConnectionForm : Form
    {
        public ConnectionForm()
        {
            InitializeComponent();
        }

        public string ServerIP
        {
            get { return tbServer.Text; }
        }

        public int ServerPort
        {
            get { return Convert.ToInt32(tbPort.Text); }
        }

        public string UserName
        {
            get { return tbUserName.Text; }
        }

        public bool IsMaster
        {
            get { return rbMaster.Checked; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrWhiteSpace(tbServer.Text))
            {
                MessageBox.Show(this, "Please insert a Server Name/IP Address", "Missing Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.None;
                return;
            }

            int port;
            if(string.IsNullOrWhiteSpace(tbPort.Text) || !int.TryParse(tbPort.Text.Trim(), out port))
            {
                MessageBox.Show(this, "Please insert a valid Port number", "Missing Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.None;
                return;
            }

            if(string.IsNullOrWhiteSpace(tbUserName.Text))
            {
                MessageBox.Show(this, "Please insert a User Name", "Missing Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                DialogResult = DialogResult.None;
                return;
            }
        }
    }
}
